﻿using System;
using System.Collections.Generic;

namespace RockBus.DataContracts
{
    public class EndpointInfoComparer : IComparer<EndpointInfo>, IEqualityComparer<EndpointInfo>
    {
        public int Compare(EndpointInfo x, EndpointInfo y)
        {
            return StringComparer.InvariantCultureIgnoreCase.Compare(x.Id, y.Id);
        }

        public bool Equals(EndpointInfo x, EndpointInfo y)
        {
            return this.Compare(x, y) == 0;
        }

        public int GetHashCode(EndpointInfo obj)
        {
            if (null == obj)
            {
                return 0;
            }

            return obj.Id.GetHashCode();
        }
    }
}